function close_poup()
{		
	$("#show_info_2").remove();
	$("#close_luu_2").remove();
	$("#khung_bg_view").hide();			
}
		
function close_thong_bao_show()
{
	$("#show_info").remove();
	$("#close_luu").remove();
}		
			
function close_khung_popup2(){
	$("#show_info_2").remove();
	$("#close_luu_2").remove();
	$("#khung_bg_view").hide();
}							
			
function kiem_trthongtin(wth)
{
	var aheight = $("#lay_thong_tin_nam_hinh").height();
	$("#khung_bg_view").css('height',(aheight)); 
	var noidung=$("#show_thong_tin").html();
	
	if(noidung!='')
	{
		$("#khung_bg_view").show();
	}

	var myWidth;
	var myHeight;
	var chia;
	var moi;
	var hedu;
	var hemoi;
	
	if(typeof(window.innerWidth) == 'number'){ 
	//Non-IE 
		 myWidth 	= window.innerWidth;
		 myHeight 	= window.innerHeight; 
	} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { 
		 //IE 6+ in 'standards compliant mode' 
		 myWidth 	= document.documentElement.clientWidth; 
		 myHeight 	= document.documentElement.clientHeight; 
	} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) { 
		 //IE 4 compatible 
		 myWidth 	= document.body.clientWidth; 
		 myHeight 	= document.body.clientHeight; 
	} 
	$("#lay_thong_tin_nam_hinh").attr('myWidth',myWidth);
	$("#lay_thong_tin_nam_hinh").attr('pupupWidth',wth);
	$("#lay_thong_tin_nam_hinh").attr('myHeight',myHeight);
	
	var viewPortHeight 	= parseInt(document.documentElement.clientHeight);
	var scrollHeight 	= parseInt(document.body.getBoundingClientRect().top);		
		
	var cont 	= document.getElementById('popup_photo');	  
	var dai		= cont.offsetHeight.toString();
	if (dai<100)
	{
		thu=250;
	}
	else
	{
		hedu 	= parseInt(viewPortHeight-dai);
		hemoi	= hedu/2;
		thu		= Math.abs(scrollHeight)+hemoi;
	}

	chia 	= myWidth-wth;
	moi		= chia/2;
		
	$(".popup_photo").css("top",Math.abs(thu)+"px");
	$(".popup_photo").css("left",moi+"px");
}

function pageLoad(){
	var cont = document.getElementById('popup_photo');	  
	var rong=cont.offsetWidth.toString();
	kiem_trthongtin(rong);
}

function set_chieucao()
{
	var hedu;
	var hemoi;
	var viewPortHeight 	= parseInt(document.documentElement.clientHeight);
	var scrollHeight 	= parseInt(document.body.getBoundingClientRect().top);		
	var dai 			= $("#popup_photo").height();

	if (dai<100)
	{
		thu = 250;
		$(".popup_photo").css("top",Math.abs(thu)+"px");
	}
	else if (dai<viewPortHeight)
	{
		hedu 	= parseInt(viewPortHeight-dai);
		hemoi	= hedu/2;
		thu		= Math.abs(scrollHeight)+hemoi;
		$(".popup_photo").css("top",Math.abs(thu)+"px");	
	}
}

$(window).scroll(function (){ 
	set_chieucao();
});


function showLoader() 
{
 	$("#loading_result").html("<div class=\"loading_bao\" style=\"position:fixed; top:50%; right:50%; text-align:center; width:120px;  color:#000000;background-color: rgba(57, 83, 83, 0.7);z-index:99999999999; padding: 8px;-moz-border-radius: 6px;border-radius: 6px;\"><div  style=\"background:#fff; height:50px;padding-top: 15px; \" >Đang tải...<br><img src='/images/ajax-loader1.gif'></div></div>").hide().fadeIn(10);
	block = true;
}

function closeLoader() {
 	$("#loading_result").html("").hide().fadeOut(100);
 	block = false;
}

function showResult(type,data) {
 	closeLoader();
 	$("#"+type+"").html(data).hide().fadeIn(100);
 	block = false;
}

function alert_msg(msg)
{
    $.ajax({
		url		: '/action.php',
        type	: 'POST',
        data	: 'act=alert&msg='+msg,
        dataType: "html",
        success	: function(data)
		{
		  showResult("luu_result",data);	
        }
    });
	return false;
}